let hi = require('./util/HttpHelper');
require('./util/TimeHelper');

let queueSign='';
function go(i){
    let url='https://ord01.vmall.com/order/pwm86t/createOrder.do';
    let time1=new Date();
    let time=new Date();
    let postData='uid=260086000306640971&user=0086137******62&name=0086137******62&ts='+time1.getTime()+'&valid=0&sign=E0DC4CCF6CC680FA9F6B5AF7DEB273D77D28AEC09FCFEB7762A4606BD4167D01&ticket=1ST-4715214-b53AnlZExejSjr9w4Goj0tldggYfNvAS-cas&hasphone=null&hasmail=null&logintype=2&rush_info=260086000306640971_1573780983_F0F5CEA67B7D969452CA566F162E9B090B8D54143F5419D2E04BCCBF4A962D00&skuId=10086239677333&skuIds=10086239677333&activityId=860120191114791&nowTime='+time.format('yyyy-MM-dd hh:mm:ss')+'&t='+time.getTime();
    let header={
        "Referer":"https://sale.vmall.com/rush/matex.html?mainSku=10086239677333&backUrl=https%3A%2F%2Fwww.vmall.com%2Fproduct%2F10086831441169.html%2310086239677333&_t="+new Date().getTime()
        ,"Origin":"https://sale.vmall.com"
        ,"Content-Type":"application/x-www-form-urlencoded"
        ,"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36"
        ,"Sec-Fetch-Mode":"cors"
        ,"Cookie":"CSRF-TIME=1573783492806; HWWAFSESID=02e9cafa900a201294; HWWAFSESTIME=1573780837769; deviceid=f64fe7ec9e764de4bf93a87e8a09544c; CSRF-TOKEN=F30C8ECD864D74B4E33018DB3BE0AEDEBE9D999EDBDE86F0; TID=f64fe7ec9e764de4bf93a87e8a09544c; _pk_ses.www.vmall.com.d1b9=*; aliToken=; uid=260086000306640971; name=0086137******62; user=0086137******62; ts=1573780982880; valid=0; sign=E0DC4CCF6CC680FA9F6B5AF7DEB273D77D28AEC09FCFEB7762A4606BD4167D01; ticket=1ST-4715214-b53AnlZExejSjr9w4Goj0tldggYfNvAS-cas; hasphone=null; hasmail=null; logintype=2; displayName=137****9062; isAuthCust=false; isEnterpriseUser=false; isFirstLogin=1; ac_loNa=137****9062; ac_lus=1; ac_lgc=0; ac_ltp=0; ac_li=true; ac_cp=1500721829297|1500721912154|1500721969899|1500722007821; rush_info=260086000306640971_1573780983_F0F5CEA67B7D969452CA566F162E9B090B8D54143F5419D2E04BCCBF4A962D00; rush_ext=260086000306640971_1_0_1573780983_76721CA4DACF4EC482EC37D48103CB2BF1077926D5DC5DB0B7EB46368DCC1E22; __ukmc=d2c4154bba60a36fc0249d303570458d260086000306640971; optBanding=1; Hm_lvt_a08b68724dd89d23017170634e85acd8=1573780840,1573780983; hasSigned=1; isqueue-860120191114791-260086000306640971=2; _dmpa_ref=%5B%22%22%2C%22%22%2C1573781644%2C%22https%3A%2F%2Fwww.vmall.com%2Fproduct%2F10086831441169.html%3FANONYMITY_LOGIN_NAME%3D137****9062%22%5D; _dmpa_ses=2eee2ac5044f5416d971b7603dd7623f55a6e978; isAuthByUid=true; vmallMyCenterMsg=0; vmallOrderCount=0; vmallOrderCountWechat=0; salePortal=1; lastReferrer=%2Fproduct%2F10086831441169.html%2310086239677333; _dmpa_ses_time=1573784965520; _dmpa_id=32210a36d9ed0952c40431069062591573781645988.1573781665.0.1573783166..; Hm_lpvt_a08b68724dd89d23017170634e85acd8=1573783494; _pk_id.www.vmall.com.d1b9=3443485bbe1c8208.1573780840.1.1573783494.1573780840.; queueSign-860120191114791-260086000306640971="+queueSign
    };
    hi.Ajax({
        url,
        form:postData,
        headers:header,
        method:"POST"
    }).then(e=>{
        console.log(e.body+i);
        if(typeof e==="string"){
            e=JSON.parse(e);
        }
        if(e.code){
            setTimeout(()=>{
                go(++i);
            },300)
        }else{
            go();
        }
    });
}
function isOk(){
    hi.Ajax({
        url:"https://yy.vmall.com/isqueue.json",
        form:"uid=260086000306640971&qid=0",
        headers:header,
        method:"POST"
    }).then(e=>{
        if(typeof e==="string"){
            e=JSON.parse(e);
        }
    });
}
go(1);